<?php
/**
 * Copyright 2013 Marek Kaszewski
 *
 * This file is part of the JHUB1 Online Community Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Jhub1_Common\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use InvalidArgumentException;
use Jhub1_Common\Model\SettingsObjects\AgentRemoteConfigurationObject;
use Jhub1_Common\Model\SettingsObjects\DateTimeObject;
use Jhub1_Common\Entity\Agents;

/** @ORM\MappedSuperclass */
abstract class POBase
{

    /**
     * @ORM\Id
     * @ORM\Column(type="string", length=28, name="id", nullable=false);
     * @ORM\GeneratedValue(strategy="NONE")
     * @var string
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=20)
     * @var string
     */
    private $created;

    /**
     * @ORM\Column(type="string", length=20, nullable=true)
     * @var string
     */
    private $updated;


    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getCreated()
    {
        $dateTime = new DateTimeObject();
        $dateTime->fromTimestamp($this->created);
        return $dateTime;
    }

    protected function setCreated(DateTimeObject $date)
    {
        $this->created = $date->toTimestamp();
    }

    public function getUpdated()
    {
        $dateTime = new DateTimeObject();
        $dateTime->fromTimestamp($this->updated);
        return $dateTime;
    }

    public function setUpdated(DateTimeObject $date)
    {
        $this->updated = $date->toTimestamp();
    }

    public function getArrayCopy()
    {
        return get_object_vars($this);
    }

    public abstract function toString();

}
